<template lang="html">
  <!--此页面需要-->
  <div class="container">

    <!--用户的相关信息-->
    <img src="../assets/logo.png" alt="" id="user-img">
    <div class="boxs id" id="id">{{detail.username}}  的歌单</div>
    <div class="boxs info" id="info">个人介绍：{{detail.username}}</div>
    <div class="boxs mail" id="mail">用户邮箱：{{detail.userMail}}</div>
    <div class="boxs phone" id="phone">用户电话：{{detail.userPhone}}</div>

    <div id="content">
      <router-link to="userinfo" id="menuleft">我的收藏</router-link>
      <div class="header">
        <div>歌曲</div>
        <div>歌手</div>
        <div>时长</div>
      </div>
      <div class="box">
        <div class="cont" v-for="(item,index) in songList" :key="index" @dblclick="playMusic(item)">
          <div class="hr"></div>
          <div>{{ }}</div>
          <div>{{item.song_name}}</div>
          <div>{{item.author}}</div>
          <div>{{item.time}}</div>
          <div><img src="../assets/del.png" alt="" class="del" @click="del(item)"></div>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
  import axios from 'axios'
  export default {
    name: 'HelloWorld',
    data() {
      return {
        detail: [],
        songurl: "",
        songList: []
      }
    },

    created() {
      let userId = this.$route.query.id
      console.log(this.$route);
      this.$http.post('http://localhost:5000/showUser', {
        user_id: userId 
      }).then((data) => {
        this.detail = data.body.data;
        console.log(data.body.data)
      })

      this.$http.get('http://localhost:5000/music/list').then((data) => {
        console.log(data.data);
        console.log(data.data.msg);
        this.songList = data.data.msg;
      })

    },
    methods: {
      del(item) {
        let id = {
          song_id: item.song_id
        }
        // console.log(item.song_id);
        this.$http.post('http://localhost:5000/music/del', id).then((data) => {
          this.$message({
            message: '删除成功',
            type: 'success'
          });
          this.$router.go(0)
          // console.log(this.songList);
        })
      },
      playMusic(item) {
        let url = {
          song_url: item.song_url,
          song_id: item.song_id
        }
        this.$http.get('http://localhost:5000/music/list', url).then(res => {
          // console.log(res.data);
          // console.log(url.song_url);
          console.log(url.song_id);
          // console.log(res.data.data[0].url);
          // this.songurl = res.data.data[0].url;
          // console.log(this.songurl);
          if (url.song_url != null) {
            this.$parent.$parent.$children[3].playmusic(url.song_id)
          } else {
            this.$message({
              message: '不能播放该歌曲哟',
              type: 'error'
            });
          }
      })
    }
  }
}
</script>

<style lang="css" scoped>
  .boxs {
    position: absolute;
    top: 100px;
    left: 100px;
    color: rgb(255, 255, 255, 0.6);
  }

  .container {
    width: 100%;
    margin: 0 auto;
  }

  #user-img {
    position: absolute;
    width: 150px;
    left: 35px;
  }

  .boxs.id {
    top: 5px;
    font-size: 30px;
    left: 241px;
  }

  .boxs.info {
    left: 241px;
    top: 75px;
    font-size: 18px;
  }

  .boxs.mail {
    left: 241px;
    top: 131px;
  }

  .boxs.phone {
    left: 450px;
    top: 131px;
  }

  #content {
    position: relative;
    left: 12px;
    top: 200px;
    color: rgb(255, 255, 255, 0.8);
    position: absolute;
  }

  #content #menuleft,#menuright {
    position: absolute;
    left: 25px;
    top: 0px;
    color: rgb(255, 255, 255, 0.8);
    font-weight: 600;
    font-size: 20px;
    text-decoration: none;
  }
  #content #menuright {
    position: absolute;
    left: 25px;
    top: 0px;
  }

  .hr {
    width: 1000px;
    height: 0px;
    background: rgba(255, 255, 255, 0.3);
  }

  .header {
    position: relative;
    top: 50px;
    height: 50px;
    width: 1100px;
  }

  .header div {
    position: absolute;
  }

  .header div:nth-child(1) {
    left: 5%;
  }

  .header div:nth-child(2) {
    left: 50%;
  }

  .header div:nth-child(3) {
    left: 85%;
  }

  .cont {
    position: relative;
    height: 50px;
  }

  .cont div:nth-child(2),
  .cont div:nth-child(3),
  .cont div:nth-child(4),
  .cont div:nth-child(5),
  .cont div:nth-child(6) {
    position: absolute;
    left: 0%;
    padding: 10px;
  }

  .cont div:nth-child(3) {
    left: 4%;
  }

  .cont div:nth-child(4) {
    left: 49.5%;
  }

  .cont div:nth-child(5) {
    left: 84.5%;
  }

  .cont div:nth-child(6) {
    left: 92%;
  }

  .box {
    position: relative;
    top: 30px;
    height: 240px;
    overflow-y: scroll;
  }

  .del {
    width: 15px;
    position: relative;
    cursor: pointer;
  }

  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  /*定义滚动条轨道 内阴影+圆角*/
  ::-webkit-scrollbar-track {
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.3);
  }

  /*定义滑块 内阴影+圆角*/
  ::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background-color: rgb(255, 255, 255, 0.7);
  }
</style>